package com.java.huxb.day02;

import java.util.concurrent.*;

class ProducerThread implements  Runnable{

    @Override
    public void run() {

    }
}

/**
 * @author huxb
 * @date 2020/3/1 0001 下午 2:06
 * 阻塞式队列防止数据丢失
 */
public class Test001 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ExecutorService executor = Executors.newCachedThreadPool();
        Future<String> result = executor.submit(new FutureTask());
        System.out.println("1111");
        for (int i = 0; i < 10; i++) {
            System.out.println(i);
        }
        System.out.println(Thread.currentThread().getName());
        String res = result.get();
        System.out.println(res);

    }


}
class FutureTask implements Callable<String> {

    @Override
    public String call() throws Exception {
        System.out.println("开始执行");

        Thread.sleep(5000);
        System.out.println(Thread.currentThread().getName());

        System.out.println("执行结束");
        return "ok";
    }
}